#!/usr/bin/env python 
# -*- coding: utf-8 -*-

"""
@author: zyx
@since: 2022/2/14 17:54
@file: parse_file.py
"""

from lxml import etree


fp = open('生意参谋.html', 'r', encoding='utf-8')
tree = etree.parse(fp, etree.HTMLParser())
tag = tree.xpath('//title/text()')
print(tag)

fp.close()

# # fp就表示本地存储的一个html文件
# fp = open('生意参谋.html', 'r', encoding='utf-8')
# # 解析本地存储的html文件中的内容
# # 实例化BeautifulSoup对象，然后把即将被解析的页面源码数据加载到了该对象中
# # 参数2，lxml是固定形式，表示指定的解析器
# soup = BeautifulSoup(fp, 'html.parser')
# fp.close()
#
# print(soup.title.string)